import { Injectable } from "@angular/core";
import { Subject } from "rxjs";
import { WebsocketService } from "./websocket";

@Injectable({
    providedIn: 'root',
})
export class DesktopService {
    private websocket: WebsocketService;
    on_refresh_screen: Subject<Blob> = new Subject();
    get is_connected(): boolean {
        return this.websocket.is_connected;
    }

    constructor() {
        this.websocket = new WebsocketService();
        this.websocket.binary.subscribe(msg => {
            this.on_refresh_screen.next(msg);
        })
    }
    init(url: string) {
        if (url)
            this.websocket.connect(url);
    }
}

